package org.marlin.http.handler;

import org.marlin.http.http.Body;
import org.marlin.http.http.Context;
import org.marlin.http.http.Header;
import org.marlin.http.http.Uri;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpUriRequest;
import org.springframework.beans.factory.config.BeanPostProcessor;


public interface HttpHandler
        extends BeanPostProcessor {
    public static final String BEAN_NAME_SUFFIX = "HttpHandler";

    default HttpUriRequest makeRequest(Uri uri, String url, Object body) {
        throw new IllegalStateException("没有实现makeRequest(Uri uri, String url, Object body)方法！");
    }


    default HttpUriRequest makeRequest(Uri uri, String url, Body params, Header headers, Context contexts, Object body) {
        return makeRequest(uri, url, (body == null) ? params : body);
    }

    <T> T handleResult(HttpResponse paramHttpResponse, Uri paramUri, Class<T> paramClass);
}

